import React, { Suspense } from "react";
import lazyLoad from "@/routers/utils/lazyLoad";
import LayoutIndex from "@/layouts/index"
import { RouteObject } from "@/routers/interface";
import Home from "@/views/home/index";
import i18n from "@/language";

const RolePage = React.lazy(() => import("@/views/system/role/index"))
const Userpage = React.lazy(() => import("@/views/system/user/index"))

// 路由模块
const commonRouter = (): Array<RouteObject> => {
	return [
		{
			element: <LayoutIndex />,
			title: i18n.t("home.home"),
			key: "homeFolder",
			skipAuth: true,
			children: [
				{
					path: "/home/index",
					// element: lazyLoad(React.lazy(() => import("@/views/home/index"))),
					element: <Home />,
					title: i18n.t("home.home"),
					skipAuth: true,
					key: "home",
				},
			],
		},
		{
			element: <LayoutIndex />,
			key: "dashboard",
			title: i18n.t("menu.dashboard.name"),
			icon: "FundOutlined",
			path: "/dashboard",
			children: [
				{
					path: "/dashboard/dataVisualize",
					element: lazyLoad(React.lazy(() => import("@/views/dashboard/dataVisualize/index"))),

					title: i18n.t("menu.dashboard.dataVisualize"),
					key: "dataVisualize",
				},
				{
					path: "/dashboard/embedded",
					element: lazyLoad(React.lazy(() => import("@/views/dashboard/embedded/index"))),
					title: i18n.t("menu.dashboard.embedded"),
					key: "embedded",
				},
			],
		},
		{
			element: <LayoutIndex />,
			key: "form",
			title: i18n.t("menu.form.name"),
			icon: "FileTextOutlined",
			path: "/form",
			children: [
				{
					path: "/form/basicForm",
					element: lazyLoad(React.lazy(() => import("@/views/form/basicForm/index"))),
					title: i18n.t("menu.form.basic"),
					key: "basicForm",
				},
				{
					path: "/form/validateForm",
					element: lazyLoad(React.lazy(() => import("@/views/form/validateForm/index"))),
					title: i18n.t("menu.form.validate"),
					key: "validateForm",
				},
				{
					path: "/form/dynamicForm",
					element: lazyLoad(React.lazy(() => import("@/views/form/dynamicForm/index"))),
					title: i18n.t("menu.form.dynamic"),
					key: "dynamicForm",
				},
			],
		},
		{
			element: <LayoutIndex />,
			key: "common",
			title: i18n.t("menu.common.name"),
			icon: "ShoppingOutlined",
			path: "/assembly",
			children: [
				{
					path: "/assembly/svgIcon",
					element: lazyLoad(React.lazy(() => import("@/views/assembly/svgIcon/index"))),
					title: i18n.t("menu.common.svg"),
					key: "svgIcon",
				},
				{
					path: "/assembly/selectIcon",
					element: lazyLoad(React.lazy(() => import("@/views/assembly/selectIcon/index"))),
					title: i18n.t("menu.common.icon"),
					key: "selectIcon",
				},
				{
					path: "/assembly/batchImport",
					element: lazyLoad(React.lazy(() => import("@/views/assembly/batchImport/index"))),
					title: "三级菜单",
					key: "batchImport",
					children: [
						{
							path: "/assembly/batchImport/m31",
							element: lazyLoad(React.lazy(() => import("@/views/dashboard/dataVisualize/index"))),
							title: "菜单1",
							key: "m31",
						},
						{
							path: "/assembly/batchImport/m32",
							element: lazyLoad(React.lazy(() => import("@/views/dashboard/embedded/index"))),
							title: "菜单2",
							key: "m32",
						},
					],
				},
			],
		},
		{
			element: <LayoutIndex />,
			key: "outlink",
			title: i18n.t("menu.outlink.link"),
			icon: "PaperClipOutlined",
			path: "/link",
			children: [
				{
					path: "/link/gitee",
					element: lazyLoad(React.lazy(() => import("@/views/link/gitee/index"))),
					isLink: "https://gitee.com/yzpass/yzpass",
					title: i18n.t("menu.outlink.gitee"),
					key: "gitee",
				},
				{
					path: "/link/gitcode",
					element: lazyLoad(React.lazy(() => import("@/views/link/gitcode/index"))),

					title: i18n.t("menu.outlink.gitcode"),
					key: "gitcode",
				},
				{
					path: "/link/juejin",
					element: lazyLoad(React.lazy(() => import("@/views/link/juejin/index"))),

					title: i18n.t("menu.outlink.juejin"),
					key: "juejin",
				},
				{
					path: "/link/myBlog",
					element: lazyLoad(React.lazy(() => import("@/views/link/myBlog/index"))),

					title: i18n.t("menu.outlink.blog"),
					key: "myBlog",
				},
			],
		},
		{
			element: <LayoutIndex />,
			key: "shop",
			title: i18n.t("menu.shop.title"),
			icon: "PaperClipOutlined",
			path: "/shop",
			children: [
				{
					path: "/shop/product",
					element: lazyLoad(React.lazy(() => import("@/views/product/index"))),
					title: i18n.t("menu.shop.product"),
					key: "product",
				},				
			],
		},
		{
			element: <LayoutIndex />,
			key: "system",
			title: i18n.t("menu.system.admin"),
			icon: "SettingOutlined",
			path: "/system",
			children: [
				{
					path: "/system/user",
					element: <Userpage />,
					title: i18n.t("menu.system.user"),
					key: "user",
				},
				{
					path: "/system/role",
					element: <RolePage />,
					title: i18n.t("menu.system.role"),
					key: "role",
				},
			],
		},
	]
};

export default commonRouter;
